package cn.otrue.patienthealthmanager.adapter;

import java.util.ArrayList;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.view.ViewGroup;

/**
 * 主界面Fragment的适配器
 * 
 * @author wujiankun
 * 
 */
public class MyFragmentPagerAdpater extends FragmentPagerAdapter {
	private ArrayList<Fragment> mFragments;

	public MyFragmentPagerAdpater(FragmentManager fm) {
		super(fm);
		mFragments = new ArrayList<Fragment>();
	}

	public void addFragment(Fragment fg) {
		mFragments.add(fg);
		this.notifyDataSetChanged();

	}

	@Override
	public Fragment getItem(int position) {
		return mFragments.get(position);
	}

	@Override
	public int getCount() {
		return mFragments.size();
	}

	@Override
	public int getItemPosition(Object object) {
		return PagerAdapter.POSITION_NONE;
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		super.destroyItem(container, position, object);
	}

}
